/**
 * 给定排列，每次交换两个元素，将其变为[1,2,...,N]
 * 输出方案
 * 模拟即可，每次记住元素及其位置
 */
#include <bits/stdc++.h>
using namespace std;

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vll = vector<llt>;

template<typename T>
void input(vector<T> & a, int n){
    a.assign(n + 1, {});
    for(int i=1;i<=n;++i) cin >> a[i];
    return;
}

template<typename T>
istream & operator >> (istream & is, vector<T> & v){
    for(auto & i : v) is >> i;
    return is;
}

llt const MOD = 1E9+7;

int N, Q;
vi A;

void work(){
    cin >> N;
    input(A, N);
    vi pos(N + 1, 0);
    for(int i=1;i<=N;++i){
        pos[A[i]] = i;
    }

    vpii output;
    for(int i=1;i<N;++i){
        int u = pos[i];
        if(u == i) continue;

        // assert(u > i);
        output.emplace_back(i, u);
        swap(A[i], A[u]);
        pos[A[u]] = u;
    }

    cout << output.size() << "\n";
    for(auto p : output) cout << p.first << " " << p.second << "\n";
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--) work();
    return 0;
}